In [11]:
using Plots,ApproxFun
plotlyjs() # works in GR too;
In [12]:
d=PeriodicInterval()^2
f=Fun((θ,ϕ)->exp(-10(sin(θ/2)^2+sin(ϕ/2)^2)),d)
A=lap(d)+.1I
u=A\f
plot(u)
Out[12]:
In [13]:
d=PeriodicInterval()*Interval()
g=Fun(z->real(cos(z)),∂(d)) # boundary data
u=[dirichlet(d);Laplacian(d)]\g
plot(u)
Out[13]:
In [15]:
dθ=PeriodicInterval(-2.,2.);dt=Interval(0,3.)
d=dθ*dt
Dθ=Derivative(d,[1,0]);Dt=Derivative(d,[0,1])
u=[I⊗ldirichlet(dt);Dt+Dθ]\Fun(θ->exp(-20θ^2),dθ)
plot(u)
Out[15]:
In [16]:
dθ=PeriodicInterval();dt=Interval(0,2.)
d=dθ*dt
Dθ=Derivative(d,[1,0]);Dt=Derivative(d,[0,1])
c=1+Fun(cos,dθ)
#timedirichlet is [u[x,0], u[-1,t], u[1,t]
u=[I⊗ldirichlet(dt);Dt+c*Dθ]\Fun(θ->exp(-20θ^2),dθ)
plot(u)
Out[16]:
In [6]:
dθ=PeriodicInterval();dt=Interval(0,2.)
d=dθ*dt
Dθ=Derivative(d,[1,0]);Dt=Derivative(d,[0,1])
a=Fun(sin,dθ)
#timedirichlet is [u[x,0], u[-1,t], u[1,t]
u=[I⊗ldirichlet(dt);Dt-a*Dθ]\Fun(θ->exp(-20θ^2),dθ)
plot(u)
Out[6]:
In [7]:
dθ=PeriodicInterval();dt=Interval(0,10.)
d=dθ*dt
ε=.01
Dθ=Derivative(d,[1,0]);Dt=Derivative(d,[0,1])
# Parentheses are a hack to get rank 2 PDE
u=[I⊗ldirichlet(dt);Dt-ε*Dθ^2-Dθ]\Fun(θ->exp(-20θ^2),dθ)
plot(u)
Out[7]:
In [8]:
dθ=PeriodicInterval(-5.,5.);dt=Interval(0,20.)
d=dθ*dt
Dθ=Derivative(d,[1,0]);Dt=Derivative(d,[0,1])
# need to specify both ic and its derivative
B=[I⊗ldirichlet(dt);I⊗lneumann(dt)]
u=pdesolve([B;Dt^2-Dθ^2],Fun(θ->exp(-20(θ-.1)^2),dθ),200)
plot(u)
Out[8]:
In [9]:
dθ=PeriodicInterval(-10.0,2.);dt=Interval(0,.03);
d=dθ*dt
Dθ=Derivative(d,[1,0]);Dt=Derivative(d,[0,1])
u=pdesolve([I⊗ldirichlet(dt);Dt+Dθ^3],Fun(θ->exp(-10θ^2),dθ),200)
plot(u)
Out[9]:
In [10]:
dθ=PeriodicInterval(0.0,1.0);dt=Interval(0,0.03)
d=dθ*dt
Dθ=Derivative(d,[1,0]);Dt=Derivative(d,[0,1]);
B=[I⊗ldirichlet(dt);I⊗lneumann(dt)]
u=pdesolve([B;Dt^2+Dθ^4],Fun(θ->exp(-200(θ-.5).^2),dθ),200)
plot(u)
Out[10]: